* "quality" parameter; its value should be in the range [0,100].
* Text chunks can be attached to PNG images by specifying parameters of
* the form "tEXt::key", where key is an ASCII string of length 1-79.
- * The values are UTF-8 encoded strings. Note however that PNG text
- * chunks are stored in ISO-8859-1 encoding, so you can only set texts
- * that can be represented in this encoding.
+ * The values are UTF-8 encoded strings.
*
* Return value: whether an error was set
**/
gchar **key,
gchar **value)
{
- *value = g_convert (text_ptr.text, -1,
- "UTF-8", "ISO-8859-1",
- NULL, NULL, NULL);
+ if (text_ptr.text_length > 0) {
+ *value = g_convert (text_ptr.text, -1,
+ "UTF-8", "ISO-8859-1",
+ NULL, NULL, NULL);
+ }
+ else {
+ *value = g_strdup (text_ptr.text);
+ }
if (*value) {
*key = g_strconcat ("tEXt::", text_ptr.key, NULL);
return TRUE;
} else {
- g_warning ("Couldn't convert tEXt chunk value to UTF-8.");
+ g_warning ("Couldn't convert text chunk value to UTF-8.");
*key = NULL;
return FALSE;
}
return;
}
- /* Extract tEXt chunks and attach them as pixbuf options */
+ /* Extract text chunks and attach them as pixbuf options */
if (png_get_text (png_read_ptr, png_info_ptr, &png_text_ptr, &num_texts)) {
for (i = 0; i < num_texts; i++) {
for (kiter = keys; *kiter; kiter++) {
if (strncmp (*kiter, "tEXt::", 6) != 0) {
- g_warning ("Bad option name '%s' passed to PNG saver", *kiter);
- return FALSE;
+ g_warning ("Bad option name '%s' passed to PNG saver", *kiter);
+ return FALSE;
}
key = *kiter + 6;
len = strlen (key);
g_set_error (error,
GDK_PIXBUF_ERROR,
GDK_PIXBUF_ERROR_BAD_OPTION,
- _("Keys for PNG tEXt chunks must have at least 1 and at most 79 characters."));
+ _("Keys for PNG text chunks must have at least 1 and at most 79 characters."));
return FALSE;
}
for (i = 0; i < len; i++) {
g_set_error (error,
GDK_PIXBUF_ERROR,
GDK_PIXBUF_ERROR_BAD_OPTION,
- _("Keys for PNG tEXt chunks must be ASCII characters."));
+ _("Keys for PNG text chunks must be ASCII characters."));
return FALSE;
}
}
"ISO-8859-1", "UTF-8",
NULL, &text_ptr[i].text_length,
NULL);
+
+#ifdef PNG_iTXt_SUPPORTED
+ if (!text_ptr[i].text) {
+ text_ptr[i].compression = PNG_ITXT_COMPRESSION_NONE;
+ text_ptr[i].text = g_strdup (values[i]);
+ text_ptr[i].text_length = 0;
+ text_ptr[i].itxt_length = strlen (text_ptr[i].text);
+ text_ptr[i].lang = NULL;
+ text_ptr[i].lang_key = NULL;
+ }
+#endif
+
if (!text_ptr[i].text) {
g_set_error (error,
GDK_PIXBUF_ERROR,
GDK_PIXBUF_ERROR_BAD_OPTION,
- _("Value for PNG tEXt chunk can not be converted to ISO-8859-1 encoding."));
+ _("Value for PNG text chunk %s can not be converted to ISO-8859-1 encoding."), keys[i] + 6);
num_keys = i;
for (i = 0; i < num_keys; i++)
g_free (text_ptr[i].text);